<template>
    <div id="my" class="login_content">
		<div class="my_info">
			<img src="@/assets/images/login/bj_01.png" />
			<div class="my_mian login_pic">
				<a href="#">
					<img src="@/assets/images/login/logo_03.png" />	
				</a>
			</div>
		</div>
		<div class="login">
			<form action="" method="">
				<p class="login_p"><span class="logo_user"><img src="@/assets/images/login/login_04.png"/></span><input type="text" name="user" placeholder="请输入用户名" autocomplete="off"/></p>
				<p class="login_p"><span class="logo_pwd"><img src="@/assets/images/login/login_07.png"/></span><input type="password" placeholder="请输入密码" name="password"/></p>
				<p class="login_sub"><input @click.prevent="submit" type="submit" id="sub" value="登录"/></p>
			</form>
		</div>
	</div>
</template>
<script>
export default {
	mounted(){
		// var $sliders = $('[data-am-widget="slider"]');
		// $sliders.not('.am-slider-manual').each(function(i, item) {
		// 	var options = UI.utils.parseOptions($(item).attr('data-am-slider'));
		// 	$(item).flexslider(options);
		// });
		console.log(window.localStorage);
	},
	methods:{
		submit(){
			var storage = window.localStorage;
			var username = $(".logo_user+input").val();
			var password = $(".logo_pwd+input").val();
			axios({
				url:'/data/user.json'
			}).then(res=>{
				// console.log(res.data);
				// res.data.forEach(element => {
				for(var element of res.data){
					console.log(element);
					console.log(typeof element);
					if(element.username === username){
						console.log("用户名正确");
						if(element.password === password){
							console.log("准许登录");
							storage['user'] = JSON.stringify(element);
							this.$router.push('/home');
							return false;
						}else{
							console.log("用户名或密码错误");
						}
					}else{
						console.log("用户名或密码错误");
					}
				}
				// console.log(this);
				// this.list = res.data;
				// console.log(this.list);
			}) 
			// this.$router.push('/home');
		}
	},
}
</script>
